package com.work.tqyb.ui.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.work.tqyb.R;
import com.work.tqyb.http.response.AirCityResponse;

import java.util.ArrayList;

public class AirLook14DayAdapter extends BaseAdapter {

    public ArrayList<AirCityResponse.CityInfo> cityList;


    @Override
    public int getCount() {
        return cityList == null ? 0 : cityList.size();
    }

    @Override
    public AirCityResponse.CityInfo getItem(int position) {
        return cityList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_city, parent, false);
            viewHolder = new ViewHolder();
            viewHolder.textView = convertView.findViewById(R.id.tv_name);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        AirCityResponse.CityInfo cityBean = cityList.get(position);
        viewHolder.textView.setText(cityBean.CityName);
        return convertView;
    }

    class ViewHolder {
        TextView textView;
    }


}
